package com.wuhao.springbootactivemq.queue;

import lombok.extern.slf4j.Slf4j;
import org.springframework.jms.annotation.JmsListener;
import org.springframework.stereotype.Component;
import javax.jms.JMSException;
import javax.jms.TextMessage;

/**
 * @author: wuhao
 * @since: 2021/11/7 17:24
 */
@Component
@Slf4j
public class QueueConsume{

       @JmsListener(destination = "${queue.name}")
       public void queueConsume(TextMessage textMessage){
           try {
               log.info("-------消费消息:{}", textMessage.getText());
           } catch (JMSException e) {
               log.error("消费消息失败!");
           }
       }
}
